<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
</head>
<style type="text/css">
    html{
        background-color: #ffffff;
    }
</style>
<body>
<form class="layui-form myData layui-form-pane" lay-filter="stuform" style="text-align: center;padding-top: 5%;">
    <input type="hidden" name="id" data-th-value="${model.id}"/>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户名：</label>
            <div class="layui-input-inline">
                <input type="text" name="username" lay-verify="required"
                       placeholder="请输入用户名" th:value="${model.username}" class="layui-input"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">姓名：</label>
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="required"
                       placeholder="请输入姓名" th:value="${model.name}" class="layui-input"/>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">电话号码：</label>
            <div class="layui-input-inline">
                <input type="text" name="userPhone" lay-verify="required"
                       placeholder="请输入电话号码" th:value="${model.userPhone}" class="layui-input"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">家庭住址：</label>
            <div class="layui-input-inline">
                <input type="text" name="userAddress" lay-verify="required"
                       placeholder="请输入家庭住址" th:value="${model.userAddress}" class="layui-input"/>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">电子邮箱：</label>
            <div class="layui-input-inline">
                <input type="text" name="email" lay-verify="required"
                       placeholder="请输入电子邮箱" th:value="${model.email}" class="layui-input"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">身份证号码：</label>
            <div class="layui-input-inline">
                <input type="text" name="idCard" lay-verify="required"
                       placeholder="请输入身份证号码" th:value="${model.idCard}" class="layui-input"/>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">性别：</label>
            <div class="layui-input-inline">
                <select name="userSex">
                    <option th:text="${model.userSex}" th:value="${model.userSex}">性别</option>
                    <option th:value="男">男</option>
                    <option th:value="女">女</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">管理员编号：</label>
            <div class="layui-input-inline">
                <input type="text" name="number" lay-verify="required" id="admin-number"
                       placeholder="请生成管理员编号" th:value="${model.number}" class="layui-input layui-disabled"/>
            </div>
            <button class="layui-btn" id="number" type="button">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                生成编号
            </button>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户类型：</label>
            <div class="layui-input-inline">
                <select name="rid">
                    <option></option>
                    <option th:each="t:${userType}" th:value="${t.id}"
                            th:selected="${model.rid==null? null: model.rid==t.id}"
                            th:text="${t.roleName}">用户类型
                    </option>
                </select>
            </div>
        </div>
    </div>
</form>
<script th:src="@{/static/layui/layui.js}"></script>
<script type="text/javascript">
    layui.config({
        base: '../../static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form','jquery'], function () {
        var form = layui.form;
        var $ = layui.jquery;

        $("#number").click(function () {
            $.post("findNnmber",function (res) {
                var num = res.substr(2,4);
                var sum = parseInt(num) + 1;
                var finalyNum ;
                if(sum < 10){
                    finalyNum = "MX00" + sum;
                }else if(sum > 10 && sum < 100){
                    finalyNum = "MX0" + sum;
                }else if(sum > 100){
                    finalyNum = "MX" + sum;
                }
                $("#admin-number").val(finalyNum);
            })
        })
        form.render();

    });
</script>
</body>
</html>